package view;

import view.elev.*;

public class Mainscreen extends javax.swing.JFrame {

    private int loginLevel;

    public Mainscreen(int loginLevel) {

        this.loginLevel = loginLevel;

        initComponents();
        
        opretGUI(loginLevel);


    }

    private void opretGUI(int niveau) {

        final int LAERER = 1;
        final int PAEDAGOG = 2;
        final int SEKRETAER = 3;
        final int ADMIN = 4;
        switch (niveau) {
            case LAERER:
                laererGUI();
                break;
            case PAEDAGOG:
                paedagogGUI();
                break;
            case SEKRETAER:
                sekretaerGUI();
                break;
            case ADMIN:
                adminGUI();
                break;
        }

    }

    private void laererGUI() {
        persAdminGUI();
        holdAdminGUI();
        trinmaalAdminGUI();
        fagAdminGUI();
        elevOplysningGUI();
        elevFagGUI();
        elevOpretGUI();
        elevAftaleGUI();
        elevLogbogGUI();
        elevPane.remove(kpersContainer);
    }

    private void paedagogGUI() {
        elevOplysningGUI();
        elevFagGUI();
        elevAftaleGUI();
        elevLogbogGUI();
        elevKPersGUI();
        elevOpretGUI();
        jTabbedPane1.remove(persAdminContainer);
        jTabbedPane1.remove(holdAdminContainer);
        jTabbedPane1.remove(fagAdminContainer);
    }

    private void sekretaerGUI() {
        persAdminGUI();
        holdAdminGUI();
        fagAdminGUI();
        elevOplysningGUI();
        elevFagGUI();
        elevOpretGUI();
        elevAftaleGUI();
        elevLogbogGUI();
        elevKPersGUI();
        jTabbedPane1.remove(trinmaalContainer);
    }

    private void adminGUI() {
        persAdminGUI();
        holdAdminGUI();
        trinmaalAdminGUI();
        fagAdminGUI();
        elevOplysningGUI();
        elevFagGUI();
        elevOpretGUI();
        elevAftaleGUI();
        elevLogbogGUI();
        elevKPersGUI();
    }

    private void persAdminGUI() {
        PersonaleAdminPanel persAdminPanelet = new PersonaleAdminPanel();
        persAdminPanelet.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        persAdminContainer.add(persAdminPanelet);
        persAdminContainer.validate();
    }

    private void holdAdminGUI() {
        HoldAdminPanel holdAdminPanelet = new HoldAdminPanel();
        holdAdminPanelet.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        holdAdminContainer.add(holdAdminPanelet);
        holdAdminContainer.validate();
    }

    private void trinmaalAdminGUI() {
        TrinmaalAdminPanel trinmaalAdminPanelet = new TrinmaalAdminPanel();
        trinmaalAdminPanelet.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        trinmaalContainer.add(trinmaalAdminPanelet);
        trinmaalContainer.validate();
    }

    private void fagAdminGUI() {
        FagAdminPanel fagAdminPanelet = new FagAdminPanel();
        fagAdminPanelet.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        fagAdminContainer.add(fagAdminPanelet);
        fagAdminContainer.validate();
    }

    private void elevOplysningGUI() {
        OplysningerPanel elevOplysninger = new OplysningerPanel();
        elevOplysninger.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        oplysningContainer.add(elevOplysninger);
        oplysningContainer.validate();
    }

    private void elevFagGUI() {
        FagPanel fagPanelet = new FagPanel();
        fagPanelet.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        fagContainer.add(fagPanelet);
        fagContainer.validate();
    }

    private void elevOpretGUI() {
        OpretPanel opretPanelet = new OpretPanel();
        opretPanelet.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        opretRedElevContainer.add(opretPanelet);
        opretRedElevContainer.validate();
    }

    private void elevAftaleGUI() {
        AftalePanel aftalePanelet = new AftalePanel();
        aftalePanelet.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        aftaleContainer.add(aftalePanelet);
        aftaleContainer.validate();
    }

    private void elevLogbogGUI() {
        LogbogPanel logPanelet = new LogbogPanel();
        logPanelet.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        logbogAftaleContainer.add(logPanelet);
        logbogAftaleContainer.validate();
    }

    private void elevKPersGUI() {
        KontaktPersonPanel kpersPanelet = new KontaktPersonPanel();
        kpersPanelet.setBounds(0, 0, fagContainer.getWidth(), fagContainer.getHeight());
        kpersContainer.add(kpersPanelet);
        kpersContainer.validate();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        hovedsideContainer = new javax.swing.JPanel();
        holdAdminContainer = new javax.swing.JPanel();
        persAdminContainer = new javax.swing.JPanel();
        fagAdminContainer = new javax.swing.JPanel();
        trinmaalContainer = new javax.swing.JPanel();
        elevAdminContainer = new javax.swing.JPanel();
        elevPane = new javax.swing.JTabbedPane();
        oplysningContainer = new javax.swing.JPanel();
        kpersContainer = new javax.swing.JPanel();
        fagContainer = new javax.swing.JPanel();
        opretRedElevContainer = new javax.swing.JPanel();
        logbogAftaleContainer = new javax.swing.JPanel();
        aftaleContainer = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Holmegaard Heldagsskole Elevadministration");
        setBounds(new java.awt.Rectangle(0, 0, 1024, 650));
        setMinimumSize(new java.awt.Dimension(1024, 650));
        setResizable(false);
        getContentPane().setLayout(null);

        jTabbedPane1.setMinimumSize(new java.awt.Dimension(1024, 728));
        jTabbedPane1.setPreferredSize(new java.awt.Dimension(1024, 728));

        hovedsideContainer.setLayout(null);
        jTabbedPane1.addTab("    Hovedside    ", null, hovedsideContainer, "");

        holdAdminContainer.setMaximumSize(new java.awt.Dimension(1024, 700));
        holdAdminContainer.setMinimumSize(new java.awt.Dimension(1024, 700));
        holdAdminContainer.setName(""); // NOI18N
        holdAdminContainer.setLayout(null);
        jTabbedPane1.addTab("        Hold        ", holdAdminContainer);

        persAdminContainer.setLayout(null);
        jTabbedPane1.addTab("     Personale     ", persAdminContainer);

        fagAdminContainer.setLayout(null);
        jTabbedPane1.addTab("         Fag         ", fagAdminContainer);

        trinmaalContainer.setLayout(null);
        jTabbedPane1.addTab("      Trinmål      ", trinmaalContainer);

        elevPane.setAlignmentX(0.2F);
        elevPane.setAlignmentY(0.2F);
        elevPane.setMinimumSize(new java.awt.Dimension(105, 200));
        elevPane.setPreferredSize(new java.awt.Dimension(105, 200));

        oplysningContainer.setMinimumSize(new java.awt.Dimension(1024, 600));
        oplysningContainer.setLayout(null);
        elevPane.addTab("   Vis Elev   ", oplysningContainer);

        kpersContainer.setLayout(null);
        elevPane.addTab("   Kontaktpersoner   ", kpersContainer);

        fagContainer.setLayout(null);
        elevPane.addTab("Potentialer/Kompetencer", fagContainer);

        opretRedElevContainer.setLayout(null);
        elevPane.addTab("Opret/Rediger Elev", opretRedElevContainer);

        logbogAftaleContainer.setLayout(null);
        elevPane.addTab("     Logbog     ", logbogAftaleContainer);

        aftaleContainer.setLayout(null);
        elevPane.addTab("  Aftaleliste  ", aftaleContainer);

        javax.swing.GroupLayout elevAdminContainerLayout = new javax.swing.GroupLayout(elevAdminContainer);
        elevAdminContainer.setLayout(elevAdminContainerLayout);
        elevAdminContainerLayout.setHorizontalGroup(
            elevAdminContainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(elevPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1019, Short.MAX_VALUE)
        );
        elevAdminContainerLayout.setVerticalGroup(
            elevAdminContainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(elevPane, javax.swing.GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("        Elever       ", elevAdminContainer);

        getContentPane().add(jTabbedPane1);
        jTabbedPane1.setBounds(0, 0, 1024, 728);

        jMenu1.setText("Filer");

        jMenuItem2.setText("Print");
        jMenu1.add(jMenuItem2);

        jMenuItem1.setText("Log ud");
        jMenu1.add(jMenuItem1);

        jMenuItem3.setText("Luk Programmet");
        jMenu1.add(jMenuItem3);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Hjælp");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel aftaleContainer;
    private javax.swing.JPanel elevAdminContainer;
    private javax.swing.JTabbedPane elevPane;
    private javax.swing.JPanel fagAdminContainer;
    private javax.swing.JPanel fagContainer;
    private javax.swing.JPanel holdAdminContainer;
    private javax.swing.JPanel hovedsideContainer;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel kpersContainer;
    private javax.swing.JPanel logbogAftaleContainer;
    private javax.swing.JPanel oplysningContainer;
    private javax.swing.JPanel opretRedElevContainer;
    private javax.swing.JPanel persAdminContainer;
    private javax.swing.JPanel trinmaalContainer;
    // End of variables declaration//GEN-END:variables
}
